home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_7.lha / 5_7 / 5_7b2.c < prev    next >
Text File  |  1993-08-08  |  517b  |  31 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Add one to the bin which contains a.
  6. / If none contains a, increment the
  7. / underflow or overflow count.
  8. include <histogram.h>
  9.  
  10. oid histogram:: add(int value)
  11.  
  12.    if (value < lovals[0])
  13. underflow++;
  14.  
  15.    else
  16. {
  17. for (int i = 1; i <= nbin; i++)
  18.     if (value < lovals[i])
  19.     {
  20.     h[i-1]++;
  21.     break;
  22.     }
  23.  
  24. if (i > nbin)
  25.     overflow++;
  26. }
  27.  
  28.    sum += value;
  29.    sqsum += value * value;
  30.  
  31.